{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "09cba5ad",
   "metadata": {},
   "source": [
    "#标识符：用于给变量或函数取名，由字母，数字，下划线组成；数字不能开头，非关键字\n",
    "\n",
    "import keyword\n",
    "print(keyword.kwlist,len(keyword.kwlist))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6fb90b7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "life is short, you need python\n"
     ]
    }
   ],
   "source": [
    "#缩进：python不需要{}来包裹代码块，代码层级之间采用冒号，换行，缩进的方式区分，通常用一个tab键缩进\n",
    "if True:\n",
    "    print('life is short, you need python')\n",
    "else:\n",
    "    print('False')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ba827622",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'\\nprint(5)\\n'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#注释\n",
    "# print（1）\n",
    "print(2)\n",
    "\n",
    "\"\"\"\n",
    "print(3)\n",
    "print(4)\n",
    "\"\"\"\n",
    "'''\n",
    "print(5)\n",
    "'''\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "21ace1be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1 1\n",
      "3 4\n",
      "4 3\n"
     ]
    }
   ],
   "source": [
    "#变量赋值\n",
    "#1.链式赋值\n",
    "a=b=c=1\n",
    "print(a,b,c)\n",
    "#2.序列解包赋值\n",
    "d,f=3,4\n",
    "print(d,f)\n",
    "#怎么用一行代码交换两个变量的值？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d1eda9f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "<class 'str'>\n",
      "<class 'tuple'>\n",
      "<class 'dict'>\n",
      "<class 'list'>\n",
      "<class 'set'>\n",
      "<class 'bool'>\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'\\nBoolean（布尔）\\nNumber（数字）\\nString（字符串）\\nList（列表）\\nTuple（元组）\\nSet（集合）\\nDictionary（字典）\\n\\n不可变数据（3 个）：Number（数字）、String（字符串）、Tuple（元组）；\\n可变数据（3 个）：List（列表）、Dictionary（字典）、Set（集合）。\\n\\n容器类型：List（列表）、Dictionary（字典）、Set（集合）、Tuple（元组）\\n一般类型：Number（数字）、String（字符串）、Boolean（布尔）\\n'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#基本数据类型\n",
    "print(type(1))\n",
    "print(type('a'))\n",
    "print(type((1,2)))\n",
    "print(type({'name':'py'}))\n",
    "print(type([1]))\n",
    "print(type({1,2}))\n",
    "print(type(True))\n",
    "\n",
    "if type(1) == int:\n",
    "    print('success')\n",
    "\n",
    "'''\n",
    "Boolean（布尔）\n",
    "Number（数字）\n",
    "String（字符串）\n",
    "List（列表）\n",
    "Tuple（元组）\n",
    "Set（集合）\n",
    "Dictionary（字典）\n",
    "\n",
    "不可变数据（3 个）：Number（数字）、String（字符串）、Tuple（元组）；\n",
    "可变数据（3 个）：List（列表）、Dictionary（字典）、Set（集合）。\n",
    "\n",
    "容器类型：List（列表）、Dictionary（字典）、Set（集合）、Tuple（元组）\n",
    "一般类型：Number（数字）、String（字符串）、Boolean（布尔）\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "98c8d6f7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1024\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "#运算符\n",
    "# 算术运算符：+，-，*，/，%，**（幂运算），//(整除运算)\n",
    "\n",
    "print(2**10)\n",
    "print(20//3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4dd15aec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "#比较运算符：>,<,==,>=,<=,!=\n",
    "\n",
    "print(1>2)\n",
    "\n",
    "#返回值一定是True，False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7122d1e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "#逻辑运算符：and，or，not对应于且，或，非\n",
    "\n",
    "print(1 and 2)\n",
    "print(3 or 4)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "bf28ddc2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n",
      "True\n",
      "False\n",
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "#成员运算符：in  （任何可迭代对象都可以使用成员运算符）\n",
    "\n",
    "print('a' in 'abc')\n",
    "print(1 in range(10))\n",
    "print(1 in (1,2,3,4,5))\n",
    "print(2 in [1,3,4])\n",
    "print(5 in {5:3})\n",
    "print(3 in {1,2,3,4})\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "56c372e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "#身份运算符：比较的是两个目标的内存地址\n",
    "a=(1,2)\n",
    "b=(1,2)\n",
    "print([1]==[1])#长得一样，==就成立\n",
    "print([2] is [2])# 长得一样且地址一样，is才成立\n",
    "print(a is b)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "6243464c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n",
      "1.0\n"
     ]
    }
   ],
   "source": [
    "#数字类型：int ,float\n",
    "print(int('12')) \n",
    "print(float(1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64d9dfb7",
   "metadata": {},
   "outputs": [],
   "source": [
    "#字符串"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
